using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
using IOLib;

namespace SHS_SE
{

    public partial class Settings : System.Windows.Forms.Form
    {
  
        public Settings()
        {
            InitializeComponent();
            for (int i = 0; i < GlobalParams.Languages.GetLength(0); i++)
            {
                comboBox10.Items.Add(GlobalParams.Languages[i, 1]);
            }
        }

        private void button1_Click(object sender, System.EventArgs e)
        {
            DialogResult = System.Windows.Forms.DialogResult.OK;
        }

        private void button2_Click(object sender, System.EventArgs e)
        {
            DialogResult = System.Windows.Forms.DialogResult.Cancel;
        }

        private int GetSelectedIndexByColor(System.Drawing.Color color)
        {
            if (color == System.Drawing.SystemColors.WindowText || color == System.Drawing.SystemColors.HighlightText || color == System.Drawing.SystemColors.Window || color == System.Drawing.SystemColors.Highlight)
                return 0;
            System.Drawing.Color color1 = System.Drawing.Color.Black;
            if (color.ToArgb() == color1.ToArgb())
                return 1;
            System.Drawing.Color color2 = System.Drawing.Color.White;
            if (color.ToArgb() == color2.ToArgb())
                return 2;
            System.Drawing.Color color3 = System.Drawing.Color.Red;
            if (color.ToArgb() == color3.ToArgb())
                return 3;
            System.Drawing.Color color4 = System.Drawing.Color.Green;
            if (color.ToArgb() == color4.ToArgb())
                return 4;
            System.Drawing.Color color5 = System.Drawing.Color.Blue;
            if (color.ToArgb() == color5.ToArgb())
                return 5;
            System.Drawing.Color color6 = System.Drawing.Color.Yellow;
            if (color.ToArgb() == color6.ToArgb())
                return 6;
            System.Drawing.Color color7 = System.Drawing.Color.Gray;
            if (color.ToArgb() == color7.ToArgb())
                return 7;
            return 0;
        }

        public void LangSel()
        {
            tabPage2.Text = GlobalParams.LanguageForm[58];
            label11.Text = GlobalParams.LanguageForm[59];
            label10.Text = GlobalParams.LanguageForm[60];
            label8.Text = GlobalParams.LanguageForm[62];
            label12.Text = GlobalParams.LanguageForm[77];
            label13.Text = GlobalParams.LanguageForm[100];
            label7.Text = GlobalParams.LanguageForm[71];
            label9.Text = GlobalParams.LanguageForm[61];
            button1.Text = GlobalParams.LanguageForm[157];
            button2.Text = GlobalParams.LanguageForm[158];
            Text = GlobalParams.LanguageForm[32];
            int[] iArr1 = new int[] { comboBox5.SelectedIndex, comboBox6.SelectedIndex, comboBox7.SelectedIndex, comboBox8.SelectedIndex };
            comboBox8.Items.Clear();
            object[] objArr5 = new object[] {
                                              GlobalParams.LanguageForm[63], 
                                              GlobalParams.LanguageForm[64], 
                                              GlobalParams.LanguageForm[65], 
                                              GlobalParams.LanguageForm[66], 
                                              GlobalParams.LanguageForm[67], 
                                              GlobalParams.LanguageForm[68], 
                                              GlobalParams.LanguageForm[69], 
                                              GlobalParams.LanguageForm[70] };
            comboBox8.Items.AddRange(objArr5);
            comboBox7.Items.Clear();
            object[] objArr6 = new object[] {
                                              GlobalParams.LanguageForm[63], 
                                              GlobalParams.LanguageForm[64], 
                                              GlobalParams.LanguageForm[65], 
                                              GlobalParams.LanguageForm[66], 
                                              GlobalParams.LanguageForm[67], 
                                              GlobalParams.LanguageForm[68], 
                                              GlobalParams.LanguageForm[69], 
                                              GlobalParams.LanguageForm[70] };
            comboBox7.Items.AddRange(objArr6);
            comboBox5.Items.Clear();
            object[] objArr7 = new object[] {
                                              GlobalParams.LanguageForm[63], 
                                              GlobalParams.LanguageForm[64], 
                                              GlobalParams.LanguageForm[65], 
                                              GlobalParams.LanguageForm[66], 
                                              GlobalParams.LanguageForm[67], 
                                              GlobalParams.LanguageForm[68], 
                                              GlobalParams.LanguageForm[69], 
                                              GlobalParams.LanguageForm[70] };
            comboBox5.Items.AddRange(objArr7);
            comboBox6.Items.Clear();
            object[] objArr8 = new object[] {
                                              GlobalParams.LanguageForm[63], 
                                              GlobalParams.LanguageForm[64], 
                                              GlobalParams.LanguageForm[65], 
                                              GlobalParams.LanguageForm[66], 
                                              GlobalParams.LanguageForm[67], 
                                              GlobalParams.LanguageForm[68], 
                                              GlobalParams.LanguageForm[69], 
                                              GlobalParams.LanguageForm[70] };
            comboBox6.Items.AddRange(objArr8);
            comboBox11.Items.Clear();
            object[] objArr9 = new object[] {
                                              GlobalParams.LanguageForm[101], 
                                              GlobalParams.LanguageForm[102] };
            comboBox11.Items.AddRange(objArr9);
            comboBox5.SelectedIndex = iArr1[0];
            comboBox6.SelectedIndex = iArr1[1];
            comboBox7.SelectedIndex = iArr1[2];
            comboBox8.SelectedIndex = iArr1[3];
        }

        private void Settings_Load(object sender, System.EventArgs e)
        {
            LangSel();
            comboBox5.SelectedIndex = GetSelectedIndexByColor(GlobalParams.clr[0]);
            comboBox6.SelectedIndex = GetSelectedIndexByColor(GlobalParams.clr[1]);
            comboBox7.SelectedIndex = GetSelectedIndexByColor(GlobalParams.clr[2]);
            comboBox8.SelectedIndex = GetSelectedIndexByColor(GlobalParams.clr[3]);
            comboBox10.SelectedIndex = GlobalParams.lang_ISO;
            comboBox11.SelectedIndex = GlobalParams.Type_ISO;
            comboBox10.SelectedIndexChanged += new System.EventHandler(ValueChanged);
        }

        private void ValueChanged(object sender, System.EventArgs e)
        {
            if ((sender is System.Windows.Forms.ComboBox) && (((System.Windows.Forms.ComboBox)sender) == comboBox10))
            {
                GlobalParams.lang_ISO = comboBox10.SelectedIndex;
                GlobalParams.Compilator(GlobalParams.Languages[comboBox10.SelectedIndex, 0], true);
                LangSel();
                comboBox11.SelectedIndex = GlobalParams.Type_ISO;
            }
        }

    } // class Settings

}

